package testsort;

import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.awt.Event;
/**
 *
 * @author BDSHADOW
 */
public class TestSort {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, InterruptedException {
        File run = new File(args[0]);
        if (args[0].endsWith(".bat")) {
            Runtime.getRuntime().exec(args[0]);
        } else {
            Runtime.getRuntime().exec(args[0] + " file1.txt " + "file2.txt");
        }
        Thread.currentThread().sleep(1000);
        FileChannel file2 = new RandomAccessFile("file2.txt", "r").getChannel();
        FileChannel answer = new RandomAccessFile("answer.txt", "r").getChannel();
        
        MappedByteBuffer mapfile2 = file2.map(FileChannel.MapMode.READ_ONLY, 0, file2.size());
        MappedByteBuffer mapanswer = answer.map(FileChannel.MapMode.READ_ONLY, 0, answer.size());
        
        if (mapfile2.equals(mapanswer)) {
            System.out.println("Succeded");
        } else {
            System.out.println("Failed");
        }
        System.in.read();
    }
}
